#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
const int N = 1e6 + 5;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    map<int, int> mp;
    int maxn = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        mp[x]++;
        maxn = max(maxn, x);
    }
    ll ans = 0;
    for (int g = 1; g <= maxn; g++) {
        for (int a = g; a <= maxn; a += g) {
            int b = a ^ g;
            if (a < b && gcd(a, b) == g && b <= maxn) {
                ans += mp[a] * mp[b];
            }
        }
    }
    cout << ans << endl;

    return 0;
}